USE CourierDatabase
GO
--create courier number
CREATE PROCEDURE CreateCourierName
@courierName VARCHAR(15) OUTPUT
AS
BEGIN
	DEClARE @ID INT
	SET @ID = (SELECT MAX(IDCourier) FROM CourierDatabase.dbo.TempTable)
	SET @courierName = 'CR' + RIGHT('00000' + CONVERT(VARCHAR(6),@ID),6)
END
GO

--call when add employee success, increase ID in IndexIDCourier
CREATE PROCEDURE IncreaseIDCourier

AS
BEGIN
	UPDATE CourierDatabase.dbo.TempTable
	SET IDCourier = IDCourier + 1

END
GO
